import java.util.HashMap;

/**
 * @version Create on 2012-11-13
 * @author Yinzi Chen
 */

public class TwoSum {

	public int[] twoSum(int[] numbers, int target) {
		int[] res = new int[2];
		HashMap<Integer, Integer> map = new HashMap<Integer, Integer>();
		for (int i = numbers.length - 1; i >= 0; --i) {
			if (!map.containsKey(numbers[i])) {
				map.put(numbers[i], i);
			}
		}
		for (int i = 0; i < numbers.length; ++i) {
			Integer idx = map.get(target - numbers[i]);
			if (idx != null && idx != i) {
				res[0] = i + 1;
				res[1] = idx + 1;
				break;
			}
		}
		return res;
	}

	public static void main(String[] args) {

	}

}
